package com.easy.common.enumbean;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;

public enum OrderStatus {
    //'待付款','已成交','已取消'
    OBLIGATION("待付款"), TRANSACTED("已成交"), CANCELLED("已取消");

    @EnumValue
    private String value;

    private OrderStatus(String value) {
        this.value = value;

    }

    @JsonCreator
    public OrderStatus convert(String val) {
        switch (val) {
            case "代付款":
                return OBLIGATION;
            case "已成交":
                return TRANSACTED;
            case "已取消":
                return CANCELLED;
            default:
                throw new RuntimeException("没有对应的枚举实例");
        }
    }

    public String valueOf() {
        return this.value;
    }

    public String toString() {
        return this.value;
    }
}
